<?php if (!defined('THINK_PATH')) exit(); /*a:2:{s:75:"/www/wwwroot/mamingwang.cn/yzf/application/admin/view/guanli/guanliadd.html";i:1556325210;s:70:"/www/wwwroot/mamingwang.cn/yzf/application/admin/view/common/head.html";i:1556002984;}*/ ?>
<!DOCTYPE html>
<html>
  
  <head>
    <meta charset="UTF-8">
    <title>聚财国际</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="/public/static/css/font.css"> 
	<link href="/favicon.ico" type="image/x-icon" rel="shortcut icon" /> 
    <link rel="stylesheet" href="/public/static/css/xadmin.css">
    <link href="/public/static/lib/layui/css/layui.css" rel="stylesheet">
    <script type="text/javascript" src="/public/static/js/jquery.min.js"></script>
    <script type="text/javascript" src="/public/static/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/public/static/js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <script type="text/css">
      #fff{
        border: red solid 1px;
      }
    </script>
  </head>
  
<body>
<div class="x-body">
    <form class="layui-form" method="post" enctype="multipart/form-data">

        <div class="layui-form-item">
            <label for="username" class="layui-form-label">
                <span class="x-red">*</span>姓名
            </label>
            <div class="layui-input-inline">
                <input type="text" id="gname" name="gname" required="" lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <!--<div class="layui-form-item">-->
            <!--<label for="L_email" class="layui-form-label">-->
                <!--<span class="x-red">*</span>选择头像-->
            <!--</label>-->
            <!--<div class="layui-upload">-->
                <!--<button type="button" class="layui-btn "  id="cover">上传图片</button>-->

            <!--</div>-->
            <!--<div class="layui-input-inline" id="preview" name="img2">-->

                <!--<input type="hidden" id="picture" name="picture" value="" >-->

            <!--</div>-->
        <!--</div>-->
		<div class="layui-form-item">
            <label for="username" class="layui-form-label">
                <span class="x-red">*</span>密码
            </label>
            <div class="layui-input-inline">
                <input type="password" id="L_pass" name="pwd"  lay-verify="pass"
                       autocomplete="off" class="layui-input" >
            </div>
        </div>
		<div class="layui-form-item">
            <label for="username" class="layui-form-label">
                <span class="x-red">*</span>确认密码
            </label>
            <div class="layui-input-inline">
                <input type="password" id="L_repass" name="repwd"  lay-verify="repass"
                       autocomplete="off" class="layui-input" onblur="return checkPass();">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="username" class="layui-form-label">
                <span class="x-red">*</span>手机号码
            </label>
            <div class="layui-input-inline">
                <input type="text" id="phone" name="phone"  lay-verify="phone"
                       autocomplete="off" class="layui-input" >
            </div>
        </div>
		<div class="layui-form-item">
            <label for="username" class="layui-form-label">
                <span class="x-red">*</span>角色
            </label> 
            <div class="layui-input-inline">
                <select name="jid" id="jname"  style="width:96px; " lay-verify="required">
				<?php if(is_array($jiao) || $jiao instanceof \think\Collection || $jiao instanceof \think\Paginator): $i = 0; $__LIST__ = $jiao;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$val): $mod = ($i % 2 );++$i;?>
				 <option value=""></option>
				 <option value="<?php echo $val['id']; ?>"><?php echo $val['jname']; ?></option>
			    <?php endforeach; endif; else: echo "" ;endif; ?>
                </select>
            </div>
        </div>
		<div>
            <div >
                <input type="hidden">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_repass" class="layui-form-label">
            </label>
            <button  class="layui-btn" lay-filter="add" lay-submit="">
               提交
            </button>
        </div>
    </form>
</div>
<script>
    layui.use(['form','layer'], function(){
        $ = layui.jquery;
        var form = layui.form
            ,layer = layui.layer;
        //自定义验证规则
        form.verify({
            nikename: function(value){
                if(value.length <6 || value.length>10){
                    return '密码位数错误！';
                }
            }
            ,pass: [/(.+){6,12}$/, '密码必须6到12位']
            ,repass: function(value){
                if($('#L_pass').val()!=$('#L_repass').val()){
                    return '两次密码不一致';
                }
            }
        });
        //监听提交
        form.on('submit(add)', function(data){
            var url="";
            $.ajax({
                type: "post",
                async:false,
                url: "<?php echo url('admin/guanli/insert'); ?>",
                data: data.field,
                dataType:'json',
                success:function (res) {
                    if(res==1)
                    {
                        layer.msg("添加成功！",{icon: 6},function () {
                            //获得frame索引
                            var index = parent.layer.getFrameIndex(window.name);
                            //关闭当前frame
                            parent.layer.close(index);
                            window.parent.location.reload();//刷新父级窗口

                        });
                        return false;
                    }
                    else
                    {
                        layer.msg("添加失败！",{icon: 5},function () {
                        });
                        return false;
                    }

                }
            })
            return false;
        });

    });
</script>
<script>
    layui.use('upload', function() {
        var upload = layui.upload;
        var $ = layui.jquery;
        var uploadInst = upload.render({
            elem:'#cover'
            ,url:'<?php echo url("admin/guanli/doUpload"); ?>'
            ,multiple: 'false'
            ,accept:'images'  // 允许上传的文件类型
            ,auto:true // 自动上传
            ,before:function (obj) {
                //console.log(obj);
                // 预览
                obj.preview(function(index,file,result) {
                    // console.log(file.name);    //图片名字
                    // console.log(file.type);    //图片格式
                    // console.log(file.size);    //图片大小
                    // console.log(result);       //图片地址
                    $('#preview').append('<img src="' + result + '" alt="' + file.name +
                        '" class="layui-upload-img" style="width:80%;objec-fit: cover;;margin-left:10px">')
                    // $('#preview').attr('src',result); //图片链接 base64

                });
                // layer.load();
            }
            // 上传成功回调
            ,done:function(res) {
                // console.log(upload);
                // console.log(res);
                if (res.code == 1) {
                    $('#picture').val($('#picture').val()+res.url);alert( $('#picture').val());
                    return layer.msg(res.msg);
                }
                return layer.msg(res.msg);
            }
            // 上传失败回调
            ,error:function(index,upload) {
                return layer.msg(res.msg);
            }
        });
    });
</script>


</body>

</html>